package com.kakaxi.mybilibili.base;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * 基础回收列表适配器
 * Created by kakaxi on 16/10/17.
 */

public abstract class BaseRecyAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView
        .Adapter<VH> {

    /** 上下文 **/
    protected Context context;
    /** 解析布局工具 **/
    protected LayoutInflater inflater;

    /** 回收列表控件 **/
    protected RecyclerView recyclerView;

    /**  **/
    private boolean mIsLoading;

    public BaseRecyAdapter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(this.context);
    }

    @Override
    public void onAttachedToRecyclerView(RecyclerView recyclerView) {
        super.onAttachedToRecyclerView(recyclerView);
        // 绑定方便使用
        this.recyclerView = recyclerView;
    }

    /**
     * 快速把xml转换为viewholoder使用的布局
     *
     * @param layoutId 布局id
     * @param parent   父布局
     * @return
     */
    protected View quickInflate(int layoutId, ViewGroup parent) {
        return inflater.inflate(layoutId, parent, false);
    }


}
